package aps

import grails.converters.JSON
import org.apache.commons.logging.LogFactory

/**
 * WaferSaw物料专用controller
 */
class WaferSawController {

    /**
     * dataSource数据源
     */
    def dataSource

    /**
     * 日志
     */
    private final static logger = LogFactory.getLog(this)

    def index() {

        def SeqNo = params.SeqNo ?: ''

        def sql = "SELECT DISTINCT o.MATERIALNO MaterialPartNo,o. CUTTEREXPOSE SawLength,o.CUTTERWIDTH SawThickness,o.MATERIALLOTNO SeqNo FROM EAP.aps_materialinfo　o where o.MATERIALLOTNO='${SeqNo}'"
        def db = new groovy.sql.Sql(dataSource)


        def list = db.rows(sql)
        def flag
        print list.size()
        if (list.size() == 0) {
            flag = 0
//            print flag
            logger.error(SeqNo + "数据库无此物料，请咨询EAP")
            render flag
        } else {
//            print list[0] as JSON
            logger.info(list[0] as JSON)
            render list[0] as JSON
        }
    }
}